
//
//  UIAboutViewController.m
//  彩票
//
//  Created by 张青花 on 15/10/8.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "UIAboutViewController.h"
#import "MessageUI/MessageUI.h"
@interface UIAboutViewController ()<MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate>

@end

@implementation UIAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    LMSettingObject *item1 = [LMSettingObject SettingObjectWithIcon:@"WeiboSina" title:@"新浪微博" type:@"1"];
    LMSettingObject *item2 = [LMSettingObject SettingObjectWithIcon:@"SmsShare" title:@"短信分享" type:@"1"];
    
    
    __weak UIAboutViewController *selfVc =self;
    
    item2.operationBlock=^{
        
        if (![MFMessageComposeViewController canSendText]) {
            return;;
        }
        
        MFMessageComposeViewController *msgVc =[[MFMessageComposeViewController alloc] init];
        
        msgVc.recipients =@[@"10085",@"10086"];
        
        msgVc.body =@"恭喜你中奖了";
        
        msgVc.messageComposeDelegate = selfVc;
        
        [selfVc presentViewController:msgVc animated:YES completion:nil];
        
        
    };
    
    LMSettingObject *item3 = [LMSettingObject SettingObjectWithIcon:@"MailShare" title:@"邮件分享" type:@"1"];
    
    item3.operationBlock =^{
      
        MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
        [mail setToRecipients:@[@"12324@qq.com"]];
        
        [mail setCcRecipients:@[@"23232@qq.com"]];
        
        [mail setBccRecipients:@[@"232311@qq.com"]];
        
        [mail setMessageBody:@"傻逼了吧" isHTML:YES];
        
        mail.mailComposeDelegate = selfVc;
        [selfVc presentViewController:mail animated:YES completion:nil];
        
        
    };
    
    LMSettingObjectGroup *group1 = [[LMSettingObjectGroup alloc] init];
    group1.items =  @[item1,item2,item3];
    
    [selfVc.settingitemArray addObject:group1];
}


- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
